import type {
  SaleOrderPickUpForm,
  SaleOrderPickUpQuery,
  SaleOrderPickUpVO,
} from './model';

import type { ID, IDS, PageResult } from '#/api/common';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

/**
 * 查询销售订单提货、回款列表
 * @param params
 * @returns 销售订单提货、回款列表
 */
export function saleOrderPickUpList(params?: SaleOrderPickUpQuery) {
  return requestClient.get<PageResult<SaleOrderPickUpVO>>(
    '/hm/saleOrderPickUp/list',
    { params },
  );
}

/**
 * 导出销售订单提货、回款列表
 * @param params
 * @returns 销售订单提货、回款列表
 */
export function saleOrderPickUpExport(params?: SaleOrderPickUpQuery) {
  return commonExport('/hm/saleOrderPickUp/export', params ?? {});
}

/**
 * 查询销售订单提货、回款详情
 * @param pickUpId id
 * @returns 销售订单提货、回款详情
 */
export function saleOrderPickUpInfo(pickUpId: ID) {
  return requestClient.get<SaleOrderPickUpVO>(
    `/hm/saleOrderPickUp/${pickUpId}`,
  );
}

/**
 * 新增销售订单提货、回款
 * @param data
 * @returns void
 */
export function saleOrderPickUpAdd(data: SaleOrderPickUpForm) {
  return requestClient.postWithMsg<void>('/hm/saleOrderPickUp', data);
}

/**
 * 新增销售订单提货、回款
 * @param data
 * @returns void
 */
export function saleOrderPickUp(data: any) {
  return requestClient.postWithMsg<void>('/hm/saleOrderPickUp/pickUp', data);
}

/**
 * 新增销售订单回款
 * @param data
 * @returns void
 */
export function saleOrderPickUpReceipt(data: any) {
  return requestClient.postWithMsg<void>('/hm/saleOrderPickUp/receipt', data);
}

/**
 * 更新销售订单提货、回款
 * @param data
 * @returns void
 */
export function saleOrderPickUpUpdate(data: SaleOrderPickUpForm) {
  return requestClient.putWithMsg<void>('/hm/saleOrderPickUp', data);
}

/**
 * 删除销售订单提货、回款
 * @param pickUpId id
 * @returns void
 */
export function saleOrderPickUpRemove(pickUpId: ID | IDS) {
  return requestClient.deleteWithMsg<void>(`/hm/saleOrderPickUp/${pickUpId}`);
}
